package com.vodafone.nowplus.android.peoplemail.filter;

/**
 * @author upt
 * Model class to hold information about a filter.
 */
public class MessageListFilter implements Comparable<MessageListFilter> {

	private String matchRegex;
	private String type="";
	private String iconId;
	private String name="";
	
	
	public MessageListFilter(String matchRegex, String type, String iconId) {
	    super();
	    this.matchRegex = matchRegex;
	    this.type = type;
	    this.name = type;
	    this.iconId = iconId;
    }

	public String getIconId() {
	    return iconId;
    }
	
	public String getType() {
	    return type;
    }
	
	public String getName() {
	    return name;
    }
	
	public void setName(String name) {
	    this.name = name;
    }
	
	public void setMatchRegex(String matchRegex) {
		this.matchRegex = matchRegex;
    }

	/**
	 * @param folderName
	 * @return true if folderName matches this filter.
	 */
	public boolean matches(String folderName) {
		if(folderName==null) {
			return false;
		}
		return folderName.matches(matchRegex);
	}
	
	@Override
	public boolean equals(Object o) {
		return (o instanceof MessageListFilter) && type.equals(((MessageListFilter)o).type)
			&& name.equals(((MessageListFilter)o).name);
	}

	@Override
    public String toString() {
	    return "MessageListFilter [type=" + type + ", name=" + name + ", matchRegex=" + matchRegex
	            + "]";
    }

	@Override
    public int compareTo(MessageListFilter another) {
	    if(iconId!=null ) {
	    	return (iconId.compareTo(another.iconId));
	    }
	    return name.compareTo(another.name);
    }
	
	
}
